package de.mhu.mandalaui.attributes;

import java.io.PrintWriter;
import java.util.LinkedList;

import de.mhu.mandalaui.bind.Element;

public class AppendBooleanAttribute extends BooleanAttribute {

	private LinkedList<Object> parts = new LinkedList<Object>();
	
	public AppendBooleanAttribute(Object ... parts) {
		for (Object p : parts)
			append(p);
	}
	
	public AppendBooleanAttribute append(Object part) {
		parts.add(part);
		if (part instanceof Element) ((Element)part).setOwner(getOwner());
		return this;
	}
	
	public void renderBindCall(PrintWriter out) {
		for (Object p : parts) {
			if (p instanceof Element) {
				((Element)p).setOwner(getOwner());
				((Element)p).renderGet(out);
			} else {
				out.print(p);
			}
		}
	}

	public boolean needFunctionImplementation() {
		return false;
	}

}
